<?php
/**
 * 年龄检查
 * User: GRAY
 * Date: 16/8/11
 * Time: 下午10:23
 */

namespace Home\Common\Hook;


use Common\Library\BusinessException;
use Common\Library\Constant;
use Common\Vendor\Hook\BaseHook;
use Think\Log;


class Age extends BaseHook
{

    public function execute($data, $params = [])
        {
            $id_num = $data['id_num'];
            $age_pass = $data['age_pass'];
            if($age_pass==1) {
                return $data;
            }
            if ($id_num) {
                $userAge = D("Customer")->getAgeById($id_num);
                //Log::write("Customer contact:".$contactCount, Log::INFO);
                if ($userAge < $params['min'] || $userAge > $params['max']) {
                    //暂不操作
                    BusinessException::throwException(Constant::INVALID_AGE);
                }
            }
            return $data;
        }
} 
